package io.renren.modules.applicationUser.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import io.renren.modules.applicationUser.dao.UserDao;
import io.renren.modules.applicationUser.entity.UserEntity;
import io.renren.modules.applicationUser.service.UserService;



@Service("userService")
public class UserServiceImpl implements UserService {
	@Autowired
	private UserDao userDao;
	
	@Override
	public UserEntity queryObject(Long id){
		return userDao.queryObject(id);
	}
	
	@Override
	public List<UserEntity> queryList(Map<String, Object> map){
		List<UserEntity> userList = userDao.queryList(map);
		List<UserEntity> userInfos = queryUserInfo();
		for (UserEntity userEntity1 : userList){
			for (UserEntity userEntity2 : userInfos){
				if(userEntity1.getUsername().equals(userEntity2.getUsername())){
					userEntity1.setRealname(userEntity2.getRealname());
					userEntity1.setDrivingdabh(userEntity2.getDrivingdabh());
					userEntity1.setDrivingsfzmhm(userEntity2.getDrivingsfzmhm());
				}
			}
		}
		return userList;
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return userDao.queryTotal(map);
	}

	@Override
	public List<UserEntity> queryUserInfo() {
		return userDao.queryUserInfo();
	}

	@Override
	public void save(UserEntity user){
		userDao.save(user);
	}
	
	@Override
	public void update(UserEntity user){
		userDao.update(user);
	}
	
	@Override
	public void delete(Long id){
		userDao.delete(id);
	}
	
	@Override
	public void deleteBatch(Long[] ids){
		userDao.deleteBatch(ids);
	}
	
}
